home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
surfdemo
/
surfevents.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-08
|
8KB
|
265 lines
#ifndef lint
static char SccsId[]= "@(#)surfevents.c V1.7 3/17/95";
#endif
/*------------------------------------------------------------------
| file name -- surfevents.c
|
| These functions handle the high level event gathering and processing.
|
| functions Description
| --------- -----------
| InitSimpleEvents Initialize the simple event handling
| HandleEvents Gather events and calls to event handler
| HandleWinEvent Handles window events
| HandlePickEvent Handles pick events inside the window
|
| handle_quit Sets the flag to quit the application
|
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "dvGR.h"
#include "VOstd.h"
#include "Tfundecl.h"
#include "surfdata.h"
#include "dvinteract.h"
#include "VOfundecl.h"
#include "VUerfundecl.h"
#include "VGfundecl.h"
#include "surffundecl.h"
#ifdef WINNT
#include <windows.h>
#endif /* WINNT */
/***************** Begin Function Declarations *************/
LOCAL void handle_quit V_P_((void));
/***************** End Function Declarations *************/
/*-----------------------------------------------------------------
|
| InitSimpleEvents()
| Performs the initialization needed for window events.
|
*/
void InitSimpleEvents
V_P_ ((void))
{
/* Setup the window events */
(VOID) VOscWinEventMask ((ULONG) (V_KEYPRESS |
V_BUTTONPRESS |
V_MOTIONNOTIFY |
V_RESIZE | V_EXPOSE |
V_WINDOW_QUIT),
(ULONG) V_END_OF_LIST);
/* Setup services functions for all window events */
(VOID) VUerWinEventPost ((OBJECT) 1, HandleWinEvent, (ADDRESS) NULL, 0,
V_EXPOSE, (ULONG) VUER_EXPOSE_EVENT);
(VOID) VUerWinEventPost ((OBJECT) 1, HandleWinEvent, (ADDRESS) NULL, 0,
V_RESIZE, (ULONG) VUER_RESIZE_EVENT);
(VOID) VUerWinEventPost ((OBJECT) 1, HandleWinEvent, (ADDRESS) NULL, 0,
V_WINDOW_QUIT, (ULONG) VUER_WINQUIT_EVENT);
/* Setup services functions for PICKS inside the window
| Remember, input objects will be drawn AFTER this posting,
| so their events can be handle with individual Service
| Functions.
*/
(VOID) VUerRectEdgePost ((OBJECT) 1, HandlePickEvent, (ADDRESS) NULL, 0,
(RECTANGLE *) NULL, (DV_BOOL) V_OUTSIDE, "", 0);
}
/*-----------------------------------------------------------------
|
| HandleEvents
| Gathers the events and passes them on to the event handler. If
| the event matches one of the requests, the appropriate service
| function will be called.
*/
void HandleEvents
V_P_ ((void))
{
OBJECT loc_event;
#ifdef WINNT
int type;
#endif /* WINNT */
/* See if there is an event to handle, only user input events
| matching those set in VOscWinEventMask will be returned.
*/
loc_event = VOloWinEventPoll( V_NO_WAIT );
#ifdef WINNT
if ( VOloValid(loc_event) )
type = VOloType(loc_event);
else
type = 0;
switch ( type )
{
case V_BUTTONPRESS:
{
DRAWPORT dp;
OBJECT obj;
OBJECT dr;
char *obj_name;
dp = TloGetSelectedDrawport( loc_event );
obj = TloGetSelectedObject( loc_event );
if( obj )
{
/* Get the object's name */
dr = TviGetDrawing( TdpGetView( dp ) );
obj_name = TdrGetObjectName( dr, obj );
}
}
break;
default:
break;
}
#endif /* WINNT */
/* If there is an event, handle it */
if (loc_event)
{
/* Let the event handler update input objects and...
| PICK events: HandlPickEvent() will be called
| WINDOW events: HandleWinEvent() will be called
*/
(VOID) VUerHandleLocEvent (loc_event);
}
}
/*-----------------------------------------------------------------
|
| HandleWinEvent
| Processes user events related to the windows. Called from
| VUerHandleLocEvent().
*/
/* ARGSUSED */
int
HandleWinEvent (client, req_id, event_type, loc, args)
OBJECT client;
EVENT_REQUEST req_id;
int event_type;
OBJECT loc;
ADDRESS args;
{
/* Perform the appropriate action based on the event type */
switch (event_type)
{
case V_RESIZE:
(VOID) TscReset (Screen);
InitControlDrawports (); /* found in surfdsp.c */
break;
case V_EXPOSE:
DrawDisplay (NOT_FIRST_TIME);
break;
case V_WINDOW_QUIT:
handle_quit ();
break;
default:
break;
}
return DV_SUCCESS;
}
/*-----------------------------------------------------------------
|
| HandlePickEvent
| Processes user events related to picks inside the window. Called
| from VUerHandleLocEvent().
|
| Checks to see if we've selected a named object. If we have it parses
| the command embedded in the name. Only the first letter of the name
| is used for the command. The commands have the following meanings:
|
| QUIT_COMMAND: Quit the program
| PLOT_COMMAND: Redraw the graph
| FORMULA_COMMAND: Draw the formula menu
| THRESHOLD_COMMAND: Draw the threshold control drawport
| ZRANGE_COMMAND: Switch to/fram auto/manual Z range
*/
/* ARGSUSED */
int
HandlePickEvent (client, req_id, pick_type, loc, args)
OBJECT client;
EVENT_REQUEST req_id;
int pick_type;
OBJECT loc;
ADDRESS args;
{
CHAR *obj_name, *cmd;
DRAWPORT dp;
OBJECT obj, dr;
/* Find the selected object */
dp = TloGetSelectedDrawport (loc);
obj = TloGetSelectedObject (loc);
if (obj)
{
/* Get the object's name */
dr = TviGetDrawing (TdpGetView (dp));
obj_name = TdrGetObjectName (dr, obj);
/* Handle the command associated with the object's name */
if (obj_name)
{
cmd = obj_name;
/* Process the current command */
switch ((INT) cmd[0])
{
/* "Quit" - QUIT the application */
case QUIT_COMMAND:
handle_quit ();
break;
/* "Plot" - PLOT the graph */
case PLOT_COMMAND:
DoPlot ();
break;
/* "FormulaArea" or "FormulaBox" - Display the FORMULA menu */
case FORMULA_COMMAND:
DrawFormulaMenu ();
break;
/* "ThresholdBox" or "ThresholdText" - Display the THRESHOLD controls */
case THRESHOLD_COMMAND:
DrawThreshControls ();
break;
/* "ZText" - Toggle ZRANGE setting */
case ZRANGE_COMMAND:
SwitchAutoZRange ();
break;
default:
break;
}
}
}
return DV_SUCCESS;
}
/*-----------------------------------------------------------------
|
| handle_quit
| Sets the flag so we quit the application.
|
*/
LOCAL void handle_quit
V_P_ ((void))
{
QuitStatus = (DV_BOOL) YES;
}